@extends('Admin.base')
@section('css')
    <link rel="stylesheet" href="/Admin/layuiadmin/css/extend/formSelects-v4.css" media="all">
@endsection
@section('content')
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" id="layui-form" action="{{route('store.savePad')}}" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label">补货品类</label>
                <div class="layui-input-block" >
                    <input type="text" name="skunum" readonly="readonly" value="{{$skunum}}" class="layui-input" >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">补货数量</label>
                <div class="layui-input-block" >
                    <input type="text" name="amount" readonly="readonly" value="{{$amount}}" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">补货单号</label>
                <div class="layui-input-block" >
                    <input type="text" name="order_no" required  lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">补货事由</label>
                <div class="layui-input-inline">
                    <input type="text" name="remark" lay-verify="required" class="layui-input">
                </div>
            </div>
            <input type="hidden" name="pad" value="{{$pad}}">
            <div class="layui-form-item">
                <div class="layui-input-block">
                    {{csrf_field()}}
                    <button type="reset" class="layui-btn layui-btn-primary">取消</button>
                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="layui-form-submit">确认补货</button>
                </div>
            </div>
        </form>
    </div>
</div>
@endsection
@section('script')
    <script>
        layui.use('form', function(){
            var form = layui.form;
            form.on('submit(layui-form-submit)', function (data) {
                $.ajax({
                    url: $(data.form).attr('action')
                    , type: 'POST'
                    , dataType: 'json'
                    , data: data.field
                    , beforeSend:function(){
                        layer.load(2);
                    }
                    , success: function (ret) {
                        if (ret.hasOwnProperty('code') && ret.code == 200) {
                            layer.msg(ret.message,{icon: 1,time:2000}, function(){
                                if(ret.redirect != 'parent') {
                                    if(ret.redirect == 'close'){
                                        window.opener=null;
                                        window.open('','_self');
                                        window.close();
                                    }else if(ret.redirect == 'current'){
                                        $(".layui-layer-close1").click();
//                                        location.reload()
                                    }else{
                                        location.href = ret.redirect;
                                    }
                                }else{
                                    location.href = document.referrer;
                                }
                            });
                            return false;
                        }
                        layer.msg(ret.message,{icon:2});
                    }

                });
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });
        });
    </script>
@endsection
